#include <stdio.h>
#include <iostream>
#include"../base.h"
using namespace std;

void divEq(Lnode* L, Lnode*& L2) {
	Lnode* slow = L, * fast = L;
	while (fast != NULL && fast->next != NULL) {
		slow = slow->next;
		fast = fast->next->next;
	}
	L2 = slow->next;
	slow ->next= NULL;
}
void recombineList(Lnode * L) {
	Lnode* L1, * L2, * tail;
	Lnode* aux1, * aux2;
	divEq(L, L2);
	L1 = L->next;
	tail = L;

	reverseList(L2);

	while (L1!=NULL&&L2!=NULL)
	{
		aux1 = L1->next;
		aux2 = L2->next;

		tail->next = L1;
		tail = tail->next;
		tail->next = L2;
		tail = tail->next;

		L1 =aux1;
		L2 = aux2;
	}
	if (L1!=NULL)
	{
		tail->next = L1;
		tail = tail->next;
	}
}
int main() {
	int A[] = { 1,2,3,4,5,6,7 };
	Lnode* L = (Lnode*)malloc(sizeof(Lnode));
	L->next = NULL;
	List_TailInsert(L, A, 7);
	printLinkList(L);
	recombineList(L);
	printLinkList(L);
	return -1;
}